package la.ge.common;

import la.common.CommonException;

public class Point {
	private double longitude;
	private double latitude;
	
	/**
	 * 
	 * @param srcStr format:"longitude,latitude"
	 * @return
	 */
	public static Point genFromStr(String srcStr) throws CommonException {
		try {
			String[] vals = srcStr.split( StrPatten.SEPARATOR_SEQ );
			double longitude;
			double latitude;
			longitude = Double.parseDouble( vals[0] );
			latitude = Double.parseDouble( vals[1] );
			return new Point( longitude, latitude );
		} catch (Exception e) {
			throw new CommonException( e );
		}
	}
	
	public Point(double longitude, double latitude) {
		super();
		this.longitude = longitude;
		this.latitude = latitude;
	}
	public double getLatitude() {
		return latitude;
	}
	public double getLongitude() {
		return longitude;
	}
	/**
	 * Constructs a <code>String</code> with all attributes
	 * in name = value format.
	 *
	 * @return a <code>String</code> representation 
	 * of this object.
	 */
	public String toString()
	{
	    final String TAB = "    ";
	    
	    String retValue = "";
	    
	    retValue = "Point ( "
	        + super.toString() + TAB
	        + "longitude = " + this.longitude + TAB
	        + "latitude = " + this.latitude + TAB
	        + " )";
	
	    return retValue;
	}
	
	
}
